var updateMenu={
    upMenuInit:function () {
        $.ajax({
            url: application.contextPath + "/menu/queryMenuByMenuId?menuId="+menuId,
            type: "GET",
            dataType: "json",
            success: function (data) {
                if(!data.isSuccess){
                    layer.msg("加载失败"+data.message);
                }else {
                    $("#menuName").val(data.data.menuName);
                    $("#menuType").find("option[value='"+data.data.menuType+"']").attr("selected",true);
                    $("#menuIcon").find("option[value='"+data.data.menuIcon+"']").attr("selected",true);
                    // sessionStorage.setItem("thisMenu",data.data);
                    $("#menuUrl").val(data.data.menuUrl);
                }
            },
            error: function (data) {
                layer.msg("网络异常，请稍后再试！");
            }
        })
    },
    commitAdd:function () {
        var data = {};
        data.menuId=menuId;
        data.menuName=$.trim($("#menuName").val());
        data.menuType=$("#menuType option:selected").val();
        data.menuIcon=$("#menuIcon option:selected").val();
        data.menuUrl=$.trim($("#menuUrl").val());
        if(null == menuName || "" == menuName || undefined == menuName){
            layer.msg("菜单名称不能为空",{icon:0});
        }else {
            $.ajax({
                url: application.contextPath+"/menu/updateMenuByMenuId",
                type:"POST",
                contentType: "application/json; charset=utf-8",
                dataType:"json",
                data:JSON.stringify({
                    parmsMap:data
                }),
                success:function (res) {
                    if("1" == res.data){
                        // sessionStorage.removeItem("thisMenu");
                        loadUtil.load({
                            container:'#homeContent',
                            url: application.contextPath+"/menu/showMenuPage?menuId=5"
                        });
                    }
                }
            });
        }
        return false;
    }
};

$(document).ready(function(){
    updateMenu.upMenuInit();
    $("#cancel").click(function(){
        loadUtil = new Load($);
        loadUtil.load({
            container:'#homeContent',
            url: application.contextPath+"/menu/showMenuPage?menuId=5"
        });
        return false;
    });
});